from neo4j import GraphDatabase

# 连接Neo4j数据库
driver = GraphDatabase.driver('bolt://localhost:7687', auth=('neo4j', 'password'))

# 查询Dragonfly的所有关系
def check_dragonfly_relations():
    with driver.session() as session:
        result = session.run('MATCH (n:Entity {name: "Dragonfly"})-[r]->(m) RETURN type(r), m.name')
        print('Dragonfly的所有关系:')
        for record in result:
            print(f'{record["type(r)"]} -> {record["m.name"]}')
    
    with driver.session() as session:
        result = session.run('MATCH (n:Entity {name: "Dragonfly"}) RETURN n.type')
        for record in result:
            print(f'Dragonfly的类型: {record["n.type"]}')

# 运行查询
if __name__ == "__main__":
    try:
        check_dragonfly_relations()
    finally:
        driver.close() 